home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
Mac_F2C_1.3.2.sit
/
Mac F2C 1.3.2
/
Mac F2C Libraries
/
libF77 Sources
/
getenv_.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-09-09
|
1KB
|
64 lines
#include "f2c.h"
/*
* getenv - f77 subroutine to return environment variables
*
* called by:
* call getenv (ENV_NAME, char_var)
* where:
* ENV_NAME is the name of an environment variable
* char_var is a character variable which will receive
* the current value of ENV_NAME, or all blanks
* if ENV_NAME is not defined
*/
#ifdef KR_headers
VOID getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen;
#else
void getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen)
#endif
{
/* IMT 9Sep95 Macintosh doesn't have any environment variables */
#if defined(SPM_F2C) || defined(TPM_F2C) || defined(CW_F2C) || defined(MPW_CW_F2C)
while( --vlen >= 0 ) /* On Mac just fill it with blanks */
*value++ = ' ';
#else
extern char **environ;
register char *ep, *fp, *flast;
register char **env = environ;
flast = fname + flen;
for(fp = fname ; fp < flast ; ++fp)
if(*fp == ' ')
{
flast = fp;
break;
}
while (ep = *env++)
{
for(fp = fname; fp<flast ; )
if(*fp++ != *ep++)
goto endloop;
if(*ep++ == '=') { /* copy right hand side */
while( *ep && --vlen>=0 )
*value++ = *ep++;
goto blank;
}
endloop: ;
}
blank:
while( --vlen >= 0 )
*value++ = ' ';
#endif /* TPM_F2C, SPM_F2C, CW_F2C and MPW_CW_F2C */
}